package com.hanhai.zrb.api.biz.dao.mybatis;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.hanhai.zrb.api.biz.dao.mybatis.base.BaseMapper;
import com.hanhai.zrb.model.user.UserFollow;

public interface UserFollowDao extends BaseMapper {

	UserFollow get(Long id);
  
	UserFollow getForUpdate(Long id);
	
	UserFollow getByFromAndTo(@Param("fromUserId")Long fromUserId,@Param("toUserId") Long toUserId);
	/**锁住其中的1行记录*/
	UserFollow getByFromAndToForUpdate(@Param("fromUserId")Long fromUserId,@Param("toUserId")Long toUserId);
	
	/**插入一条关注记录*/
	void follow(UserFollow follow);
    /**取消关注*/
	void unfollow(UserFollow follow);
    /**更新follow的状态*/
	void updateStatus(@Param("id")Long id,@Param("status")Integer status);
	
	List<UserFollow> followingListByUpdateTime(@Param("fromUserId") Long fromUserId,
			@Param("updateTime") Date updateTime, @Param("limit") Integer limit);

	List<UserFollow> followedListByUpdateTime(@Param("toUserId") Long toUserId,
			@Param("updateTime") Date updateTime, @Param("limit") Integer limit);
	
	/**我关注了哪些人*/
	List<Long> followingListAllToUserId(Long fromUserId);

	/**我被哪些人关注*/
	List<Long> followedListAllFromUserId(Long toUserId);

	List<UserFollow> followingListPage(Long fromUserId);

	List<UserFollow> followedListPage(Long toUserId);
	
}
